PATHMac OS 8 and 9 Developer Documentation > Interapplication Communication > AppleScript for Scripters >

AppleScript Language Guide

   

Defining a Subroutine With Positional Parameters

The definition for a subroutine with positional parameters lists the order in which to list parameters when calling the subroutine and the statements to be executed when the subroutine is called.

SYNTAX
( on | to ) subroutineName ( [ paramVariable [, paramVariable ]...] )
    [ global variable [, variable ]...]
    [ local variable [, variable ]...]
    [ statement ]...
end [ subroutineName ]

where

subroutineName (an identifier) is the name of the subroutine.

paramVariable (an identifier) is a parameter variable for the actual value of the parameter. You use this identifier to specify the parameter in the body of the subroutine.

variable is an identifier for either a global or local variable that can be used in the handler. The scope of a local variable is the handler. The scope of a global variable can extend to any other part of the script, including other handlers and script objects. For detailed information about the scope of local and global variables, see Scope of Script Variables and Properties.

statement is any AppleScript statement.

The parentheses that enclose the series of positional parameters in the syntax definition are a required part of the language. They are shown in bold to distinguish them from parentheses that show grouping but are not part of the language. The parentheses must be included even if the subroutine definition doesn't include any parameters.

For more information, see Examples of Subroutines With Positional Parameters.


© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)